package com.csun.cmny.provider.web.frontend;

import com.csun.cmny.provider.model.domain.OpcAppVersion;
import com.csun.cmny.provider.resolver.CmnyMessageSource;
import com.csun.cmny.provider.service.OpcAppVersionService;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-09-23 10:25
 * @Description: the class app version controller
 */
@Slf4j
@RestController
@RequestMapping(value = "/api/app/version", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class OpcAppVersionController {

    @Resource
    private OpcAppVersionService opcAppVersionService;
    @Resource
    private CmnyMessageSource cmnyMessageSource;

    /**
     * query ios shelf status
     *
     * @param opcAppVersion the opc app version
     *
     * @return  the 1 - 正式版本 0 - 上架版本
     */
    @PostMapping(value = "/queryIosShelfStatus")
    public Wrapper queryIosShelfStatus(@RequestBody OpcAppVersion opcAppVersion) {

        String status = opcAppVersionService.queryIosShelfStatus(opcAppVersion);

        //return WrapMapper.ok(status);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource
                .getMessage("operation.success", null), status);
    }

}
